/*/////////////////////////////////////////////////////////////////////////////////
/// An
///    ___   ____ ___ _____ ___  ____
///   / _ \ / ___|_ _|_   _/ _ \|  _ \
///  | | | | |  _ | |  | || | | | |_) |
///  | |_| | |_| || |  | || |_| |  _ <
///   \___/ \____|___| |_| \___/|_| \_\
///                              File
///
/// Copyright (c) 2008-2009 Ismail TARIM <ismail@royalspor.com> and the Ogitor Team
//
//This program is free software; you can redistribute it and/or modify it under
//the terms of the GNU Lesser General Public License as published by the Free Software
//Foundation; either version 2 of the License, or (at your option) any later
//version.
//
//This program is distributed in the hope that it will be useful, but WITHOUT
//ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
//FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public License along with
//this program; if not, write to the Free Software Foundation, Inc., 59 Temple
//Place - Suite 330, Boston, MA 02111-1307, USA, or go to
//http://www.gnu.org/copyleft/lesser.txt.
////////////////////////////////////////////////////////////////////////////////*/

#pragma once

namespace Ogitors
{

class OgitorExport CMaterialEditor : public CBaseEditor
{
    friend class CMaterialEditorFactory;
public:
    static OgitorsPropertyDefMap propertyDefs;

    virtual void     processParameters(Ogre::NameValuePairList &params);
    virtual bool     load();
    virtual bool     unLoad();
	virtual void     getObjectProperties(Ogre::NameValuePairList &retList);
	void             setPropertiesLevel(int level, int id)
    {
        m_PropertyLevel = level;
        m_PropertyID = id;
    };
    virtual bool	 setupPropertiesWnd(bool present);
	virtual void     showBoundingBox(bool bShow);

	/// This function is called when user right clicks a property to get that property specific popup menu
	/// returns false if no menu present (Disabled Menu Items has a "D" prefix where Enabled Menu Items have "E" prefix
	virtual bool                 getObjectContextMenu(UTFStringVector &menuitems);
    /// This function is called when user selects a menuitem from ContextMenu
	virtual void                 onObjectContextMenu(int menuresult);
    /// Overridden by Editor Objects to Import Object Dependant Properties
    virtual void                 restore(Ogre::NameValuePairList &retList);
    /// Gets the Handle to encapsulated object
    inline virtual void         *getHandle() {return static_cast<void*>(&m_Handle);};
    /// Returns the Factory associated with this object
	static CBaseEditorFactory   *getFactory();
    /// Returns the Factory associated with this object can be overridden
	virtual CBaseEditorFactory  *getFactoryDynamic();
    virtual Ogre::AxisAlignedBox getAABB() {return Ogre::AxisAlignedBox::BOX_NULL;};
	virtual Ogre::SceneNode     *getNode() {return 0;};

    inline int                   getPropertyLevel() {return m_PropertyLevel;};
    inline int                   getPropertyID() {return m_PropertyID;};


protected:
	Ogre::MaterialPtr  m_Handle;
    Ogre::StringVector m_MaterialNames;
    Ogre::StringVector m_CompareFunctions;
	Ogre::StringVector m_CullingModes;
	Ogre::StringVector m_ShadingModes;
	Ogre::StringVector m_PolygonModes;
    int                m_PropertyLevel;
    int                m_PropertyID;
    
	CMaterialEditor();
	virtual     ~CMaterialEditor();

    void _displayTechnique(int id);
    void _displayPass(int techid, int id);
    void _displayTextureUnits(Ogre::Pass *pass, unsigned int BINDING); 
};

class OgitorExport CMaterialEditorFactory: public CBaseEditorFactory
{
public:
  CMaterialEditorFactory();
  virtual ~CMaterialEditorFactory() {};
  virtual void Init();
  virtual CBaseEditor *CreateObject(CBaseEditor **parent, Ogre::NameValuePairList &params);
};
}

